<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        form {
            /* 居中表单 */
            margin: 0 auto;
            width: 400px;
            /* 显示表单的轮廓 */
            padding: 1em;
            border: 1px solid #CCC;
            border-radius: 1em;
        }

        ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        form li+li {
            margin-top: 1em;
        }

        label {
            /* 确保所有label大小相同并正确对齐 */
            display: inline-block;
            width: 90px;
            text-align: right;
        }

        input,
        textarea {
            /* 确保所有文本输入框字体相同
     textarea默认是等宽字体 */
            font: 1em sans-serif;

            /* 使所有文本输入框大小相同 */
            width: 300px;
            box-sizing: border-box;

            /* 调整文本输入框的边框样式 */
            border: 1px solid #999;
        }

        input:focus,
        textarea:focus {
            /* 给激活的元素一点高亮效果 */
            border-color: #000;
        }

        textarea {
            /* 使多行文本输入框和它们的label正确对齐 */
            vertical-align: top;

            /* 给文本留下足够的空间 */
            height: 5em;
        }

        .button {
            /* 把按钮放到和文本输入框一样的位置 */
            padding-left: 90px;
            /* 和label的大小一样 */
        }

        button {
            /* 这个外边距的大小与label和文本输入框之间的间距差不多 */
            margin-left: .5em;
        }
    </style>
</head>

<body>
    <p>test!</p>
    <form action="/my-handling-form-page" method="post">
        <div>
            <label for="name">Name:</label>
            <input type="text" id="name">
        </div>
        <div>
            <label for="mail">E-mail:</label>
            <input type="email" id="mail">
        </div>
        <div>
            <label for="msg">Message:</label>
            <textarea id="msg"></textarea>
        </div>

        <div class="button">
            <button type="submit">Send your message</button>
        </div>
    </form>
    <p>form2:</p>
    <form action="http://foo.com" method="get">
        <div>
            <label for="say">What greeting do you want to say?</label>
            <input name="say" id="say" value="Hi">
        </div>
        <div>
            <label for="to">Who do you want to say it to?</label>
            <input name="to" id="to" value="Mom">
        </div>
        <div>
            <button>Send my greetings</button>
        </div>
    </form>
</body>

</html>